package com.yanqu.road.entity.activity.peakstronghold;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

// 据点战门客赚钱缓存
@FieldTypeAnnotation(tableName = "t_c_union_ability_cache", autoSave = true)
public class CrossUnionAbilityCacheData extends DataObject {
    @FieldTypeAnnotation(select = true, update = true, desc = "活动id", isIndex = true)
    private int activityId;
    @FieldTypeAnnotation(update = true, desc = "商会id", isIndex = true)
    private String unionId;
    @FieldTypeAnnotation(desc = "玩家历史最高门客赚力")
    private Map<Long, BigInteger> userAbility = new ConcurrentHashMap<>();

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public String getUnionId() {
        return unionId;
    }

    public void setUnionId(String unionId) {
        this.unionId = unionId;
    }

    public Map<Long, BigInteger> getUserAbility() {
        return userAbility;
    }

    public void setUserAbility(ConcurrentHashMap<Long, BigInteger> userAbility) {
        this.userAbility = userAbility;
    }

    public void updateUserAbility(long userId, BigInteger ability) {
         if(userAbility.containsKey(userId))         {
             if (userAbility.get(userId).compareTo(ability) != 0) {
                 userAbility.put(userId, ability);
                 setUpdateOption();
             }
         } else {
             userAbility.put(userId, ability);
             setUpdateOption();
         }
    }
}
